// JavaScript Document
	function showcabindetail(content){
		$.get(links+"checkrate/getdetailcabin?c="+content,function(data){
			if(data!="nodata"){
				$("#dialog-modal").html(data);
				$( "#dialog-modal" ).dialog({
					 modal: true,
					 width:450,
					 title:"Cabin details"
				});
			}
		});
	}
	function showcondition(type){
		if(type==0){
			$("#dialog-modal").html('<ul style="float:left;margin:0;padding:0 0 0 13px;"><li style="padding-top:12px;">If canceled or modified up to 7 days before date of arrival, no fee will be charged.<br/></li><li style="padding-top:12px;">If canceled or modified up to 3 days before date of arrival, 50 percent of the total price of the reservation will be charged.<br/></li><li style="padding-top:12px;">If canceled or modified later or in case of no-show, the total price of the reservation will be charged.<br/></li></ul>');
			$( "#dialog-modal" ).dialog({
				 modal: true,
				 width:450,
				 title:"Booking condition"
			});
		}else if(type==1){
			$("#dialog-modal").html('This booking is Non-refundable and cannot be amended or modified. Failure to arrive at our cruise will be treated as a No-show and no refund will be given');
			$( "#dialog-modal" ).dialog({
				 modal: true,
				 width:450,
				 title:"Booking condition"
			});
		}
	}
	var selectedcabin=Array();
	function checkbeforesend(){
		if(selectedcabin.length==0){
			alert("Choice your cabin, please");
			return false;
		}
	}
	function bookcharter(element,idrowcabin,idcabin,price,priceextra){
		
		var check=-1;
		
		for(i=0;i<selectedcabin.length;i++){
			if(selectedcabin[i].id==idrowcabin)
				check=i;
		}
		if(check>-1){
			selectedcabin.splice(check,1);
			enablerow(idrowcabin);
			$(element).html("Book");
		}else{
			
			var objPrice=checkprice(idrowcabin,idcabin,price,priceextra);
			
			disablerow(idrowcabin);
//			selectedcabin.push(objPrice);
			$(element).html("Booked");
//			alert($("#"+idrowcabin+" > .price").length);
			$.post(links+"home/cart/add",{singler:0,doubler:0,twinr:0,adults:objPrice.numberadult,child:0,infants:0,price:objPrice.price,ship:0,title:'title',roomid:idcabin,image:'img',startdate:'',endate:'',rate_tour:'',vat:'',prices:0},function(result){
								if(result == "false!"){
									$("#errors").show();
									$("#errors").html("You must complete booking for one cruise before booking for the next one, <a style='color:#00F' href='"+links+"your-cart#ship_info'>Click here</a> to see cruises you have already booked or <a style='color:#00F' href='"+links+"home/cart/emptycart'>Click here</a> to empty cart");
									//alert("only ship!");
									return false;
								}else{
									$okie.html("<span style='color:green;font-size:10px' class='removeok'>Ok</span>");
									$cart.load(links+'home/cart');
									$cart.fadeIn("slow");
								}
							});
		}
	}
	function disablerow(idrowcabin){
		$("#"+idrowcabin+" > td > select").attr("disabled","disabled");
	}
	function enablerow(idrowcabin){
		$("#"+idrowcabin+" > td > select").removeAttr("disabled");
	}
	function checkprice(idrowcabin,idcabin,pricetwo,priceextra){
		
		var n=parseInt($("#"+idrowcabin+" td > select[name='extraperson']").val());
		var p=pricetwo+priceextra*n;
		var numberadult=n+2;
		$(document.getElementById(idrowcabin)).find(".price").html("$"+p);
		//$(document.getElementById("#totalps"+idrowcabin)).value = p;
		var r={"price":p,"id":idrowcabin,"idcabin":idcabin,"numberadult":numberadult,"numberdouble":0,"numbersingle":0,"numbertwin":0,"numberchild":0,"numberinfant":0};
		return r;
	}
	function totalprice(){
		var r=0;
		for(i=0;i<selectedcabin.length;i++){
			r+=selectedcabin[i].price;
		}
		return r;
	}
	function showroomcharter(links,data){
		if(data.numbernight == 0){
			alert("Please select a program!");
			return false;
		}
		document.getElementById("loader").innerHTML = "<img src='"+links+"public/images/ajax-loading.gif' />";
		//var datasend={};
		document.getElementById("change").disabled = false;
		document.getElementById("fromdate").innerHTML = data.start;
		document.getElementById("shows").style.display = "block";
		$.post(links+"home/shipajax/charter",data,function(res){
			//$status = document.getElementById("statusval").value;
			document.getElementById("show_room").innerHTML = res;
			//document.getElementById("valstatus").value = $status;
			document.getElementById("loader").innerHTML ="";
		});
	}
